import java.util.*;

public class LuckyNumberGenerator {
    
    public static List<String> func(int level, String prefix, int count, Set<String> usedNumbers) {
        List<String> result = new ArrayList<>();
        Set<String> generatedNumbers = new HashSet<>();
        
        // 根据 level 和 prefix 来决定靓号的生成规则
        String pattern = getPattern(level);
        
        while (result.size() < count) {
            // 生成符合规则的靓号
            String number = generateLuckyNumber(pattern);
            
            // 判断是否符合前缀要求
            if (prefix != null && !prefix.isEmpty() && !number.startsWith(prefix)) {
                continue;
            }
            
            // 确保生成的靓号不在 usedNumbers 中
            if (usedNumbers.contains(number) || generatedNumbers.contains(number)) {
                continue;
            }
            
            // 添加到结果集
            result.add(number);
            generatedNumbers.add(number);
        }
        
        return result;
    }
    
    private static String getPattern(int level) {
        // 根据等级返回相应的生成规则
        switch (level) {
            case 30: return "6-digit";
            case 40: return "5-digit";
            case 50: return "ABCDB/ABCBA/ABCAB/AABBCC/ABAAA/AAAABC";
            case 60: return "AABCB/ABCBBB/AABCC/AABBB/AAAABB/AAABBB";
            case 70: return "ABBBC/ABBCC/AAABC/ABCCC/AABBC/AAAAAB/ABBBBB";
            case 80: return "AAAAB/ABAAA/AABAA/AAABA/AAABB/AABBB/ABBBB/ABBBA";
            case 100: return "4-digit";
            default: throw new IllegalArgumentException("Invalid level");
        }
    }
    
    private static String generateLuckyNumber(String pattern) {
        // 根据pattern生成符合规则的靓号（模拟方法）
        if (pattern.equals("6-digit")) {
            return generateRandomNumber(6);
        } else if (pattern.equals("5-digit")) {
            return generateRandomNumber(5);
        } else if (pattern.equals("4-digit")) {
            return generateRandomNumber(4);
        }
        // 其他复杂的规则可以进一步实现
        // 在这里，先仅处理数字类型生成的情况
        return generateRandomNumber(6); // 默认返回一个6位数
    }
    
    private static String generateRandomNumber(int length) {
        Random random = new Random();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < length; i++) {
            sb.append(random.nextInt(10)); // 生成0-9的数字
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        Set<String> usedNumbers = new HashSet<>();
        usedNumbers.add("123456");
        usedNumbers.add("654321");
        
        List<String> luckyNumbers = func(50, "", 24, usedNumbers);
        System.out.println(luckyNumbers);
    }
}
